﻿using IHotelDal;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;

namespace HotelDal
{
    public class FinanceDAL : IFinanceDAL
    {
        MyDbcontext db = new MyDbcontext();
        /// <summary>
        /// 添加汇总
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public int Add(HuiZone s)
        {
            db.HuiZone.Add(s);
            return db.SaveChanges();
        }
        /// <summary>
        /// 汇总表的删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DelHuiZong(int id)
        {
            var hid = db.HuiZone.Find(id);
            db.HuiZone.Remove(hid);
            return db.SaveChanges();
        }

        public HuiZone Detita(int id)
        {
            var list = new HuiZone();
            return list;
            //var hid = db.huizongs.Find(id);
            //db.huizongs.
        }

        public List<HuiZone> Show()
        {
            var h = db.HuiZone.ToList();
            return h;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Update(int id)
        {
            var hid = db.HuiZone.Find(id);
            db.Entry<HuiZone>(hid).State = EntityState.Modified;
            return db.SaveChanges();
        }
    }
}
